package com.artPreter.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.artPreter.pojo.DepartContentSection;
import com.artPreter.mapper.DepartContentSectionMapper;
import com.artPreter.pojo.DepartSectionTemp;
import com.artPreter.service.IDepartContentSectionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * <p>
 * 内容栏目表 服务实现类
 * </p>
 *
 * @author jarvis
 * @since 2024-11-19
 */
@Service
public class DepartContentSectionServiceImpl extends ServiceImpl<DepartContentSectionMapper, DepartContentSection> implements IDepartContentSectionService {


    @Override
    public List<DepartContentSection> getList(DepartContentSection departContentSection) {
        if(departContentSection.getDepartId()!=null&&departContentSection.getSectionId()!=null){
            LambdaQueryWrapper <DepartContentSection> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(DepartContentSection::getDepartId,departContentSection.getDepartId());
            queryWrapper.eq(DepartContentSection::getSectionId,departContentSection.getSectionId());
            return this.baseMapper.selectList(queryWrapper);
        }
        return null;
    }

    /**
     * 导航栏数据
     * @return
     */
    @Override
    public List<DepartContentSection> getMenuList() {
        LambdaQueryWrapper <DepartContentSection> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DepartContentSection::getDepartId,"358a5bee-7600-4c88-803c-1c92e74b8dc7");
        queryWrapper.orderByAsc(DepartContentSection::getSort);
        List<DepartContentSection> result = this.baseMapper.selectList(queryWrapper);
        for (int i = 0; i < result.size(); i++) {
            if(result.get(i).getContentType()==5){
                result.get(i).setContent("/index/article/list?cid="+result.get(i).getId());
            }
            if(result.get(i).getContentType()==1){
                result.get(i).setPageDetail(result.get(i).getContent());
                result.get(i).setContent("/index/page?cid="+result.get(i).getId());
            }
        }
        return result;
    }
}
